﻿<%@ Page Title="" Language="C#" MasterPageFile="~/PortalParts/Portal.Master" AutoEventWireup="true" CodeBehind="BBSReplyDetails.aspx.cs" Inherits="ZHDJ.Web.Portal.Forum.BBSReplyDetails" %>

<%@ Import Namespace="NPOI.POIFS.NIO" %>
<%@ Import Namespace="ZHDJ.Data.Models.Forum" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../../Resource/themes/Default/CSS/party.common.css" rel="stylesheet" type="text/css" />
    <link href="../../Resource/themes/Default/CSS/portal.widgets.css" rel="stylesheet" type="text/css" />
    <link href="../../Resource/themes/default/css/party.portal.css" rel="stylesheet" type="text/css" />
    <script src="../../Resource/js/jquery/jquery.pagination.js"></script>
    <script type="text/javascript">
        var isFirst = true;
        var paginationPara = {
            num_edge_entries: 1, //边缘页数
            num_display_entries: 4, //主体页数
            callback: pageselectCallback,
            items_per_page: 20, //每页显示1项
            prev_text: "上一页",
            next_text: "下一页",
            link_to: "javascript:void(0);",
            current_page: 0 //当前页面
        }

        function pageselectCallback(pageIndex, jq) {
            if (!isFirst) {
                window.location.href = "BBSReplyDetails.aspx?ForumID=" + $("#ctl00_ContentPlaceHolder1_hdForumID").val() + "&PageIndex=" + pageIndex;
            } else {
                isFirst = false;
            }

        }

        $(function () {
            paginationPara.items_per_page = $("#ctl00_ContentPlaceHolder1_hdPageSize").val();
            paginationPara.current_page = $("#ctl00_ContentPlaceHolder1_hdPageIndex").val();
            var totalCount = parseInt($("#ctl00_ContentPlaceHolder1_hdTotalCount").val());

            $("#pagination").pagination(totalCount, paginationPara);
        });
        function DelForum(id, isReply) {
            if (confirm("确定删除吗？")) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json",
                    url: "BBSReplyDetails.aspx/DelForum",
                    data: "{id:'" + id + "',isReply:'" + isReply + "'}",
                    dataType: "json",
                    success: function (msg) {
                        alert('删除成功！');
                        if (isReply == true) {
                            window.location.href = "BBSReplyDetails.aspx?ForumID=<%=ForumID %>&PageIndex=" + $("#ctl00_ContentPlaceHolder1_hdPageIndex").val();
                        } else {
                            window.location.href = "BBSList.aspx?TypeID=<%=TypeID %>";
                        }
                    }, error: function (XMLHttpRequest) {
                        alert(XMLHttpRequest.status);
                    }
                });
            }
        }

        function SetJinHuaForum(id, isJinHua) {
            var msg, msg2;
            if (isJinHua == true) {
                msg = "确定要推荐此帖为精华帖?";
                msg2 = "推荐精华帖成功";
            }
            else {
                msg = "确定要取消此帖为精华帖?";
                msg2 = "取消精华帖成功";
            }
            if (confirm(msg)) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json",
                    url: "BBSReplyDetails.aspx/SetJinHuaForum",
                    data: "{id:'" + id + "',isJinHua:'" + isJinHua + "'}",
                    dataType: "json",
                    success: function (msg) {
                        alert(msg2);
                        window.location.href = "BBSReplyDetails.aspx?ForumID=<%=ForumID %>&PageIndex=" + $("#ctl00_ContentPlaceHolder1_hdPageIndex").val();

                    }, error: function (XMLHttpRequest) {
                        alert(XMLHttpRequest.status);
                    }
                });
            }
        }

        function SetTopForum(id, isTop) {
            var msg, msg2;
            if (isTop == true) {
                msg = "确定要设置此帖置顶显示?";
                msg2 = "设置置顶显示成功";
            }
            else {
                msg = "确定要取消此帖置顶显示?";
                msg2 = "取消置顶显示成功";
            }
            if (confirm(msg)) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json",
                    url: "BBSReplyDetails.aspx/SetTopForum",
                    data: "{id:'" + id + "',isTop:'" + isTop + "'}",
                    dataType: "json",
                    success: function (msg) {
                        alert(msg2);
                        window.location.href = "BBSReplyDetails.aspx?ForumID=<%=ForumID %>&PageIndex=" + $("#ctl00_ContentPlaceHolder1_hdPageIndex").val();

                    }, error: function (XMLHttpRequest) {
                        alert(XMLHttpRequest.status);
                    }
                });
            }
        }

        function SetJuJiaoForum(id, isFocus) {
            var msg, msg2;
            if (isFocus == '1') {
                msg = "确定要设置此帖聚焦显示?";
                msg2 = "设置聚焦显示成功";
            }
            else if (isFocus == '2') {
                msg = "确定要设置此帖聚焦置顶显示?";
                msg2 = "设置聚焦置顶显示成功";
            } else if (isFocus == '3') {
                msg = "确定要取消此帖聚焦置顶显示?";
                msg2 = "取消聚焦置顶显示成功";
            } else {
                msg = "确定要取消此帖聚焦显示?";
                msg2 = "取消聚焦显示成功";
            }
            var focus = isFocus;
            if (isFocus == '3') {
                focus = "1";
            }
            if (confirm(msg)) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json",
                    url: "BBSReplyDetails.aspx/SetJuJiaoForum",
                    data: "{id:'" + id + "',isFocus:'" + focus + "'}",
                    dataType: "json",
                    success: function (msg) {
                        alert(msg2);
                        window.location.href = "BBSReplyDetails.aspx?ForumID=<%=ForumID %>&PageIndex=" + $("#ctl00_ContentPlaceHolder1_hdPageIndex").val();
                    }, error: function (XMLHttpRequest) {
                        alert(XMLHttpRequest.status);
                    }
                });
            }
        }

        function Repleylevel(level) {
            var r = window.frames;
            if ($("#ctl00_ContentPlaceHolder1_div_post").size() > 0) {
                //r[0].document.body.innerHTML = "<p>回复" + level + "#<p>";
                $("#ctl00_ContentPlaceHolder1_iContent2").contents().find("iframe").eq(0).contents().find("body").html("<p>回复" + level + "#<p>");
                //window.scrollTo(0, $(window).height() - 240);
                $(document).scrollTop($(document).height() - 240);
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:HiddenField ID="hdForumID" runat="server" Value="0" />
    <asp:HiddenField ID="hdPageIndex" runat="server" Value="0" />
    <asp:HiddenField ID="hdTotalCount" runat="server" Value="0" />
    <asp:HiddenField ID="hdPageSize" runat="server" Value="20" />
    <div class="party-navigation">
        当前位置：<a href="../../Default.aspx">首页</a> > <a href="BBSIndex.aspx">论坛首页</a> >
        <asp:Label ID="lblTitle2" runat="server" />
    </div>
    <div class="bgline"></div>
    <div>
        <div class="DivWidth">
            <div runat="server" id="divFatie" style="overflow: hidden; margin: 20px;">
                <a class="bbs-btn-newtopic" id="ATop" href="BBSPost.aspx?TypeID=<%=TypeID %>" style="float: right;">发布帖子
                </a>
            </div>
        </div>
        <div class="BBS-List DivWidth">
            <%if (DataSource.Rows.Count > 0)
                {
                    int i = 1;
                    if (PageIndex > 1)
                    {
                        i = (PageIndex - 1) * PageSize + 1;
                    }
                    foreach (System.Data.DataRow dr in DataSource.Rows)
                    {
                        System.Data.DataTable dt = PartyForum.GetUserInfo(dr["Author"].ToString());
                        if (dt.Rows.Count < 1) continue;
                        System.Data.DataRow row = dt.Rows[0];
                        if (dr["IsTpoic"].ToString() == "0")
                        {%>
            <table class="BBS-Reply-Content" border="0" cellpadding="2" cellspacing="0">
                <tbody>
                    <tr>
                        <td class="BBS-Reply-UserInfo" rowspan="3">
                            <div class="poster">
                                <span class="online">
                                    <%=dr["UserName"] %></span>
                            </div>

                            <div>
                                <div class="avatar">
                                    <img width="120px" height="120px" src="<%=GetBBSIamge(row["BBSImage"].ToString()) %>" />
                                </div>
                            </div>
                            <div class="bbs-info">
                                <table align="center" style="text-align: left; margin: auto">
                                    <tr style="height: 20px">
                                        <td>发帖：
                                        </td>
                                        <td>
                                            <a href="MyHistoryList.aspx"
                                                target="_blank">
                                                <%=row["PostNum"]%></a>
                                        </td>
                                        <td>精华：
                                        </td>
                                        <td>
                                            <a href="MyEssenceList.aspx"
                                                target="_blank">
                                                <%=row["JinHuaNum"]%></a>
                                        </td>
                                    </tr>
                                    <tr style="height: 20px">
                                        <td>回复：
                                        </td>
                                        <td>
                                            <a href="MyReplyList.aspx"
                                                target="_blank">
                                                <%=row["ReplyCount"]%></a>
                                        </td>
                                        <td>浏览：
                                        </td>
                                        <td style="text-align: left">
                                            <a href="MyBrowseList.aspx"
                                                target="_blank">
                                                <%=row["BrowseNum"]%></a>
                                        </td>
                                    </tr>
                                    <tr style="height: 20px">
                                        <td>积分：
                                        </td>
                                        <td>
                                            <%=row["ScoreNum"]%>
                                        </td>
                                        <td>等级：
                                        </td>
                                        <td>
                                            <%=row["LevelNum"]%>
                                        </td>
                                    </tr>
                                </table>
                                <table align="center" style="text-align: left; margin: auto">
                                    <tr style="height: 30px; font-weight: bold; display: none">
                                        <td style="width: 65px">注册时间：
                                        </td>
                                        <td>
                                            <%=row["CreateTime"] != System.DBNull.Value && row["CreateTime"].ToString()!=""? Convert.ToDateTime(row["CreateTime"]).ToString("yyyy-MM-dd") : ""%>
                                        </td>
                                    </tr>
                                    <tr style="font-weight: bold;">

                                        <td colspan="2">
                                            <%=row["BranchName"]%>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                        <td class="BBS-Reply-ContentInfo">
                            <div class="topictitle">
                                <h3 style="font-size: 16px; margin: 0;">
                                    <%
                                        string title = dr["ForumTitle"].ToString();
                                        if (dr["IsFirst"] != null && Convert.ToBoolean(dr["IsFirst"]) == true)
                                            title = "<span style=\"color:Red\">[置顶]&nbsp</span>" + dr["ForumTitle"].ToString();
                                        if (dr["IsEssence"] != null && Convert.ToBoolean(dr["IsEssence"]) == true)
                                            title += "<img src=\"../../Resource/themes/Default/Images/Widget/bbs_folder_jin.gif\"/>";

                                        Response.Write(title);
                                    %>
                                </h3>
                            </div>
                            <div class="pi">
                                <div class="postinfo">
                                    <img src="../../Resource/Themes/Default/Images/Widget/BBS_member.gif" />
                                    <em>发表于 <span>
                                        <%=dr["CreateTime"]%></span><span style="margin: 10px">来源：<%=string.IsNullOrEmpty(dr["Source"].ToString()) ? "网站" : dr["Source"].ToString()=="1"?"网站":"客户端"%></span></em>

                                    <div class="postinfo-DIV">
                                        <a>
                                            <%=(PageSize*PageIndex+(i++)) %>#</a>
                                    </div>
                                </div>
                            </div>
                            <div class="postmessage defaultpost">
                                <%=dr["ForumContent"]%>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="plc"></td>
                    </tr>
                    <tr>
                        <td class="plc"></td>
                    </tr>
                    <tr>
                        <td class="BBS-Reply-UserInfo">&nbsp;
                        </td>
                        <td class="BBS-Reply-ContentInfo">
                            <div class="p_control">
                                <cite class="y" style="margin-right: 10px;"><a onclick="window.parent.scrollTo(0,0);return false;"
                                    href="#">TOP</a></cite> <cite class="y" style="margin-right: 10px;"><a onclick="$(document).scrollTop($(document).height() - 240);"
                                        href="javascript:void(0)">回复</a> </cite>
                                <%if (IsSystemAdministrator())
                                    { %>
                                <cite class="y" style="margin-right: 10px;"><a id="a_Delete" onclick="DelForum('<%=dr["ID"]%>',false)"
                                    href="#">删除帖子</a> </cite><cite class="y" style="margin-right: 10px;"><a id="a_Edit"
                                        href="BBSPost.aspx?ForumID=<%=ForumID %>&TypeID=<%=TypeID %>">编辑帖子</a> </cite>
                                <%if (dr["IsEssence"] != null && Convert.ToBoolean(dr["IsEssence"]) == true)
                                    { %>
                                <cite class="y" style="margin-right: 10px;"><a id="a_deljing" onclick="SetJinHuaForum('<%=dr["ID"]%>',false)"
                                    href="#">取消精华</a> </cite>
                                <%}
                                    else
                                    {%>
                                <cite class="y" style="margin-right: 10px;"><a id="a_addjing" onclick="SetJinHuaForum('<%=dr["ID"]%>',true)"
                                    href="#">设置精华</a> </cite>
                                <%} %>
                                <%if (dr["IsFirst"] != null && Convert.ToBoolean(dr["IsFirst"]) == true)
                                    { %>
                                <cite class="y" style="margin-right: 10px;"><a id="a_canceTop" onclick="SetTopForum('<%=dr["ID"]%>',false)"
                                    href="#">取消置顶</a> </cite>
                                <%}
                                    else
                                    {%>
                                <cite class="y" style="margin-right: 10px;"><a id="a_top" onclick="SetTopForum('<%=dr["ID"]%>',true)"
                                    href="#">设置置顶</a> </cite>
                                <%} %>
                                <% if (CurrentUser.LoginID.Trim().Equals("admin"))
                                    {
                                        if (dr["IsFocus"] != null && (dr["IsFocus"].ToString() == "1" || dr["IsFocus"].ToString() == "2"))
                                        { %>
                                <cite class="y" style="margin-right: 10px;"><a id="a_canceFocus" onclick="SetJuJiaoForum('<%= dr["ID"] %>','0')"
                                    href="#">取消聚焦</a> </cite>
                                <% }
                                    else
                                    { %>
                                <cite class="y" style="margin-right: 10px;"><a id="a_Focus" onclick="SetJuJiaoForum('<%= dr["ID"] %>','1')"
                                    href="#">设置聚焦</a> </cite>
                                <% }

                                    } %>
                                <%}
                                    else if (IsForumMaster())
                                    {
                                %>
                                <cite class="y" style="margin-right: 10px;"><a id="a_Delete2" onclick="DelForum('<%=dr["ID"]%>',false)"
                                    href="#">删除帖子</a> </cite><cite class="y" style="margin-right: 10px;"><a id="a_Edit2"
                                        href="BBSPost.aspx?ForumID=<%=ForumID %>&TypeID=<%=TypeID %>">编辑帖子</a> </cite>
                                <%} %>
                            </div>
                        </td>
                    </tr>
                </tbody>
                <tbody>
                    <tr class="threadad">
                        <td class="postauthor"></td>
                        <td class="adcontent"></td>
                    </tr>
                </tbody>
            </table>
            <%}
                else
                { %>
            <table class="BBS-Reply-Content" border="0" cellpadding="2" cellspacing="0">
                <tbody>
                    <tr>
                        <td class="BBS-Reply-UserInfo" rowspan="3">
                            <div class="poster">
                                <span class="online">
                                    <%=dr["UserName"] %></span>
                            </div>
                            <div>
                                <div class="avatar">
                                    <img width="120px" height="120px" src="<%=GetBBSIamge(row["BBSImage"].ToString()) %>" />
                                </div>
                                <div class="bbs-info">
                                    <table align="center" style="text-align: left; margin: auto">
                                        <tr style="height: 20px">
                                            <td>发帖：
                                            </td>
                                            <td>
                                                <a href="MyHistoryList.aspx"
                                                    target="_blank">
                                                    <%=row["PostNum"]%></a>
                                            </td>
                                            <td>精华：
                                            </td>
                                            <td>
                                                <a href="MyEssenceList.aspx"
                                                    target="_blank">
                                                    <%=row["JinHuaNum"]%></a>
                                            </td>
                                        </tr>
                                        <tr style="height: 20px">
                                            <td>回复：
                                            </td>
                                            <td>
                                                <a href="MyReplyList.aspx"
                                                    target="_blank">
                                                    <%=row["ReplyCount"]%></a>
                                            </td>
                                            <td>浏览：
                                            </td>
                                            <td style="text-align: left">
                                                <a href="MyBrowseList.aspx"
                                                    target="_blank">
                                                    <%=row["BrowseNum"]%></a>
                                            </td>
                                        </tr>
                                        <tr style="height: 20px">
                                            <td>积分：
                                            </td>
                                            <td>
                                                <%=row["ScoreNum"]%>
                                            </td>
                                            <td>等级：
                                            </td>
                                            <td>
                                                <%=row["LevelNum"]%>
                                            </td>
                                        </tr>
                                    </table>
                                    <table align="center" style="text-align: left; margin: auto">
                                        <tr style="height: 30px; font-weight: bold; display: none">
                                            <td style="width: 65px">注册时间：
                                            </td>
                                            <td>
                                                <%=row["CreateTime"] != System.DBNull.Value && row["CreateTime"].ToString()!=""? Convert.ToDateTime(row["CreateTime"]).ToString("yyyy-MM-dd") : ""%>
                                            </td>
                                        </tr>
                                        <tr style="font-weight: bold;">

                                            <td colspan="2">
                                                <%=row["BranchName"]%>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                        </td>
                        <td class="BBS-Reply-ContentInfo">
                            <div class="pi">
                                <div class="postinfo">
                                    <img src="../../Resource/Themes/Default/Images/Widget/BBS_member.gif" />
                                    <em>发表于 <span>
                                        <%=dr["CreateTime"]%></span><span style="margin: 10px">来源：<%=string.IsNullOrEmpty(dr["Source"].ToString()) ? "网站" : dr["Source"].ToString()=="1"?"网站":"客户端"%></span></em>
                                    <div class="postinfo-DIV">
                                        <a>
                                            <%=(PageSize*PageIndex+(i++)) %>#</a>
                                    </div>
                                </div>
                            </div>
                            <div class="postmessage defaultpost">
                                <%=dr["ForumContent"]%>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="plc"></td>
                    </tr>
                    <tr>
                        <td class="plc"></td>
                    </tr>
                    <tr>
                        <td class="BBS-Reply-UserInfo">&nbsp;
                        </td>
                        <td class="BBS-Reply-ContentInfo">
                            <div class="p_control">
                                <cite class="y" style="margin-right: 10px;"><a onclick="window.scrollTo(0,0)"
                                    href="#">TOP</a> </cite><cite class="y" style="margin-right: 10px;"><a onclick="Repleylevel('<%=(PageSize*PageIndex+i-1) %>');"
                                        href="javascript:void(0)">回复</a> </cite>
                                <%if (IsSystemAdministrator() || IsForumMaster() || IsReplyMaster(dr["ID"].ToString()))
                                    { %>
                                <cite class="y" style="margin-right: 10px;"><a id="delReply" onclick="DelForum('<%=dr["ID"]%>',true)"
                                    href="#">删除回复</a> </cite>
                                <%} %>
                            </div>
                        </td>
                    </tr>
                </tbody>
                <tbody>
                    <tr class="threadad">
                        <td class="postauthor"></td>
                        <td class="adcontent"></td>
                    </tr>
                </tbody>
            </table>
            <%
                        }
                    }
                } %>
        </div>
        <div class="BBS-Page DivWidth" style="background: transparent; border: none; height: auto;">
            <table style="width: 100%">
                <tr>
                    <td style="width: 230px; display: none">
                        <div runat="server" id="divFatie2">
                            <a class="bbs-btn-newtopic" id="Abom" href="BBSPost.aspx?TypeID=<%=ForumID %>">
                                <img src="../../Resource/Themes/Default/Images/Widget/bbs_btn_newtopic.png" />
                            </a>
                        </div>
                    </td>
                    <td style="width: auto;">
                        <div class="pagination">
                            <div id="pagination">
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </div>

        <div id="div_post" class="DivWidth" style="height: 517px;" runat="server">
            <iframe id="iContent2" frameborder="0" scrolling="no" marginheight="0" runat="server" marginwidth="0" style="margin: 0px; padding: 0px; width: 100%; height: 517px;" src=""></iframe>
        </div>

    </div>
</asp:Content>
